#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int* twoSum(int* nums, int numsSize, int target, int* returnSize) {
    *returnSize = 2;
    int * rs = (int *)malloc(*returnSize * sizeof(int));
    bool notFound = true;
    for(int i = 0; notFound && i < numsSize - 1; i++)
        for(int j = i + 1; notFound && j < numsSize; j++){
            if(nums[i] + nums[j] == target){
                notFound = false;
                rs[0] = i;
                rs[1] = j;
            }
        }
    return rs;
}

int main() {
    int nums[] = {2,7,11,15};
    int numsSize = sizeof(nums) / sizeof(int);
    int target = 22;
    int rsSize;
    int * rs = twoSum(nums, numsSize, target, &rsSize);
    printf("two sum's subscript --- %d %d \n", rs[0], rs[1]);
    return 0;
}